<!-- 输送带型号 -->
<template>
  <div class="ConveyorModel">
    <div>
      <el-card class="box-card">
        <CommonForm />
      </el-card>

      <!-- 公共导航 -->
      <el-card>
        <NavTab />
      </el-card>
      <el-card>
        <div class="tableForm">
          <el-form ref="form1" label-width="100px" :model="form">
            <el-row>
              <el-col :span="8">
                <el-form-item label="设备编号">
                  <el-input v-model="form.EQUIPMENT_ID" clearable style="width: 150px" />
                </el-form-item>
              </el-col>

              <el-col :span="8">
                <div class="block">
                  <el-form-item label="设备类型">
                    <el-cascader
                      v-model="form.TYPE_ID"
                      autocomplete="on"
                      clearable
                      :options="options"
                      placeholder="请选择设备类型"
                      :props="{ checkStrictly: true }"
                      style="width: 150px"
                      @change="handleChange"
                    />
                  </el-form-item>
                </div>
              </el-col>

              <el-col :span="8">
                <el-form-item label="输送带型号">
                  <el-input v-model="form.CONVEYOR_MODEL" autocomplete="on" clearable style="width: 150px" />
                </el-form-item>
              </el-col>

              <el-col :span="24" style="margin-left: 60%">
                <el-form-item>
                  <el-button @click="reset('form1')">
                    <vui-icon icon="refresh-line" />
                    重置
                  </el-button>
                  <el-button type="primary" @click="onQuery">
                    <vui-icon icon="search-2-line" />
                    查询
                  </el-button>
                  <el-button v-model="submitData" :disabled="fbDisabled" :type="btntype" @click="onSubmit">
                    <vui-icon icon="save-line" />
                    {{ btnMsg }}
                  </el-button>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
        </div>

        <div class="detailTable">
          <el-table ref="multipleTable" border :data="tableData" highlight-current-row style="width: 100%" tooltip-effect="dark">
            <el-table-column type="selection" width="55" />

            <el-table-column align="center" label="设备编号" prop="EQUIPMENT_ID" width="120" />

            <el-table-column align="center" label="设备类型" prop="E_TYPE_NAME" width="120" />
            <el-table-column align="center" label="长(固定端)(mm)" prop="LENGTH" width="120" />

            <el-table-column align="center" label="有效宽度(mm)" prop="WIDTH" width="120" />

            <el-table-column align="center" label="高(mm)" prop="HEIGHT" width="120" />

            <el-table-column align="center" label="线速度(m/min)" prop="LINEAR_VELOCITY" width="120" />

            <el-table-column align="center" label="电机功率(KW)" prop="MOTOR_POWER" width="120" />

            <el-table-column
              align="center"
              :filter-method="filterTag"
              filter-placement="bottom-end"
              :filters="filters"
              label="输送带型号"
              prop="CONVEYOR_MODEL"
              width="300"
            />

            <el-table-column align="center" label="确认输送带型号" prop="CONVEYOR_MODEL_CONFIRM" width="300">
              <template #default="scope">
                <span style="width: 150px; display: inline-block; text-align: center; margin-right: 50px">
                  {{ scope.row.CONVEYOR_EQUIPMENT_MODEL }}
                </span>

                <vui-icon icon="add-circle-line" style="color: rgb(24, 144, 255); font-size: 24px" @click="chooseClick(scope.row, scope.$index)" />
              </template>
            </el-table-column>

            <el-table-column align="center" label="输送线价格" prop="CONVEYOR_PRICE" width="120" />

            <el-table-column align="center" label="是否热熔" prop="HOT_MELTING_FLAG" width="80" />
            <!-- <el-table-column align="center" label="热熔费用" prop="HOT_MELTING_PRICE" width="120" /> -->
            <el-table-column align="center" label="热熔费用" prop="HOT_MELTING_PRICE" width="120">
              <template #default="scope">
                <span>{{ Math.floor(scope.row.HOT_MELTING_PRICE * 100) / 100 }}</span>
              </template>
            </el-table-column>

            <el-table-column align="center" fixed="right" label="操作" prop="operate" width="120">
              <template #default="scope">
                <el-button :disabled="disbaledFlag" size="small" type="primary" @click="savedata(scope.row)">
                  <vui-icon icon="save-line" />
                  保存
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-card>
    </div>
  </div>

  <!-- //隐藏的二级界面 -->
  <el-dialog v-model="dialogTableVisible" title="选择输送带" width="80%">
    <el-card>
      <el-form ref="form2" label-width="80px" :model="form">
        <el-form-item label="品牌">
          <el-select v-model="form.BRAND_ID" placeholder="请选择品牌">
            <el-option v-for="(item, index) of brandOptions" :key="index" :label="item.label" :value="item.value" />
          </el-select>

          <el-button style="right: 5%; position: absolute; top: 2%" @click="resetSel('form2')">
            <vui-icon icon="refresh-line" />
            重置
          </el-button>
          <el-button style="right: 25%; position: absolute; top: 2%" type="primary" @click="dialogQuery">
            <vui-icon icon="search-2-line" />
            查询
          </el-button>
        </el-form-item>
      </el-form>
    </el-card>

    <el-card>
      <el-table ref="selectTable" border :data="epGridData1" @select="selectData" @selection-change="selectRow">
        <el-table-column type="selection" width="55" />

        <el-table-column align="center" label="品牌" prop="BRAND_NAME" width="300" />
        <el-table-column align="center" label="型号" property="EQUIPMENT_MODEL" width="300" />
        <el-table-column align="center" label="单价" width="300">
          <template #default="scope">
            <span>{{ Math.floor(scope.row.PRICE_UNTAX * 100) / 100 }}</span>
          </template>
        </el-table-column>
      </el-table>
    </el-card>

    <el-switch v-model="value1" active-text="热熔" inactive-text="不热熔" @change="showTable" />

    <el-card id="grid2" style="display: none">
      <el-table ref="multipleTable" border :data="epGridData2" show-summary :span-method="objectSpanMethod" sum-text :summary-method="getSummaries">
        <el-table-column align="center" label="类型" property="TYPE" width="150" />
        <el-table-column align="center" label="计量单位" property="UOM" width="100" />
        <el-table-column align="center" label="单价" prop="PRICE_UNTAX" width="120">
          <template #default="scope">
            <el-input v-model="scope.row.PRICE_UNTAX" placeholder="请输入单价" @blur="checkPrice(scope.row.PRICE_UNTAX, scope.$index)" />
          </template>
        </el-table-column>
        <el-table-column label="限制条件" property="XZTJ" width="200">
          <template #default="scope">
            <el-input v-model="scope.row.XZTJ" :placeholder="scope.row.placeholder" />
          </template>
        </el-table-column>
        <el-table-column align="center" label="数量" property="QTY" width="120">
          <template #default="scope">
            <el-input v-model="scope.row.QTY" placeholder="请输入数量" @blur="checkQty(scope.row.QTY, scope.row.PRICE_UNTAX, scope.$index)" />
          </template>
        </el-table-column>
        <el-table-column align="center" label="金额" property="MONEY" width="120">
          <template #default="scope">
            <el-input v-model="scope.row.MONEY" placeholder="请输入金额" @blur="checkMoney(scope.row.MONEY, scope.$index)" />
          </template>
        </el-table-column>
        <el-table-column label="备注" property="NOTES" width="300">
          <template #default="scope">
            <el-input v-model="scope.row.NOTES" placeholder="请输入备注" :rows="10" type="textarea" />
          </template>
        </el-table-column>
      </el-table>
    </el-card>

    <div class="rightbtn">
      <el-button size="medium" type="primary" @click="confirmMsg">确认</el-button>
      <el-button size="medium" @click="dialogTableVisible = false">取消</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import CommonForm from '@bqms/components/ComTable.vue'
  import settingJson from '@bqms/common/index'
  import { getList } from '../api/home'
  import { GFCD } from '@/utils/utils'
  import NavTab from '@/project/bqms/components/NavTab.vue'

  //横向滚动条
  // let el
  // let tableBodyWrapDom = window.document.getElementsByClassName('el-table__body-wrapper')
  // let tableBodyDom = window.document.getElementsByClassName('el-table__header-wrapper')

  // function handle() {
  //   if (!el) return
  //   // top为dom上侧距离可视窗口顶部的值
  //   const { top: tableBodyDomTop } = tableBodyWrapDom.getBoundingClientRect()
  //   if (tableBodyDomTop > window.innerHeight || tableBodyWrapDom.classList.contains('is-scrolling-none')) {
  //     // 此时列表在可视窗口的下侧不可见区域，因此不做任何修改
  //     tableBodyWrapDom.style.height = 'unset'
  //     tableBodyWrapDom.style.marginBottom = 'unset'
  //   } else {
  //     // 窗口高度 - 列表距顶部值 且 不超过自身实际值
  //     let wrapHeight = Math.min(window.innerHeight - tableBodyDomTop, tableBodyDom.offsetHeight)
  //     tableBodyWrapDom.style.height = wrapHeight + 'px'
  //     // 需要用marginBottom填充，以保持列表原有高度，避免页面的纵向滚动条变化导致页面滚动的不流畅
  //     // 可以通过注释这一行代码观察其效果差异
  //     tableBodyWrapDom.style.marginBottom = tableBodyDom.offsetHeight - wrapHeight + 'px'
  //     // console.log(tableBodyWrapDom.style.marginBottom,'marginBottom')
  //   }
  // }

  export default {
    name: 'ConveyorModel',
    components: {
      CommonForm,
      NavTab,
    },
    data() {
      return {
        chooseIndex: '',
        color: '',
        DOCNO: '',
        BRAND_ID: '',
        notes: '', //热熔备注
        btntype: '', //发布数据按钮类型
        fbDisabled: false,
        HOT_FLAG: 'N', //热熔标记
        totalLen: '', //长度大于
        totalHei: '', //高度大于
        disbaledFlag: false, //按钮是否禁用标记
        btnMsg: '发布数据', //发布数据文字
        tabledataIndex: '', //选中下标
        //界面2选中的型号
        EQUIPMENT_NO: '',
        //界面2的价格
        PRICE: '',
        //订单状态
        orderStatus: '',
        checkDataFlag: false,
        placeHolderArr: [
          {
            label: '长度大于(mm)',
          },
          {
            label: '高度大于(mm)',
          },
        ], //输入框提示语
        totalPrice: '', //缓存热熔费用
        filters: [], //筛选数组
        rule: /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d+)$/, //正数的正则
        postUrl: '', //请求地址
        srcArr: [], //路径集合
        flag: true, //请求表示
        value1: false, //表格显示隐藏标识
        dialogTableVisible: false, //模态框显示和隐藏
        settingJson: settingJson,
        selectFormData: {
          //分页参数
          '#LIMIT#': 1,
          '#PAGE_SIZE#': 9999,
        },
        options: [], //级联下拉框数组
        form: {
          DOCNO: '',
          EQUIPMENT_ID: '',
          TYPE_ID: '',
          BRAND_ID: '',
          PRICE_UNTAX: '',
          CONVEYOR_MODEL: '',
        },
        tableData: [], //首页表格存值
        epGridData1: [], //二级界面上部分表格存值
        epGridData2: [
          //二级界面下部分表格存值
          {
            TYPE: '起步费:',
            UOM: '次',
            PRICE_UNTAX: '',
            XZTJ: '',
            QTY: '',
            MONEY: '',
            NOTES: '',
            placeholder: '长度大于(mm)',
          },
          {
            TYPE: '接驳数量:',
            UOM: '条',
            PRICE_UNTAX: '',
            XZTJ: '',
            QTY: '',
            MONEY: '',
            NOTES: '',
          },
          {
            TYPE: '车辆费用:',
            UOM: '元/公里',
            PRICE_UNTAX: '',
            XZTJ: '',
            QTY: '',
            MONEY: '',
            NOTES: '',
          },
          {
            TYPE: '机台费用:',
            UOM: '元/台.天',
            PRICE_UNTAX: '',
            XZTJ: '',
            QTY: '',
            MONEY: '',
            NOTES: '',
            placeholder: '高度大于(mm)',
          },
          {
            TYPE: '高空接驳:',
            UOM: '条',
            PRICE_UNTAX: '',
            XZTJ: '',
            QTY: '',
            MONEY: '',
            NOTES: '',
          },
        ],
        brandOptions: [], //品牌下拉框存值
      }
    },

    watch: {
      DOCNO: {
        deep: true,
        handler(newval) {
          console.log('订单1123', newval)
          //清空表格
          this.tableData = []
        },
      },
      // list() {
      //   // 当列表数据源发生变化时，再次触发
      //   this.$nextTick(handle)
      // },
    },

    // mounted() {
    //   el = this.$el // 当前组件的Dom对象，避免操作到本组件之外的Dom
    //   tableBodyWrapDom = el.querySelector('.el-table__body-wrapper')
    //   tableBodyDom = el.querySelector('.el-table__body')
    //   // 监听事件
    //   window.addEventListener('scroll', handle, true)
    //   window.addEventListener('resize', handle, true)
    // },
    // unmounted() {
    //   // 在组件销毁时取消监听
    //   window.removeEventListener('scroll', handle, true)
    //   window.removeEventListener('resize', handle, true)
    // },
    //onshow方法
    activated() {
      if (this.tableData.length == 0) {
        this.fbDisabled = true
      } else {
        this.fbDisabled = false
      }

      //获取单据状态
      this.orderStatus = this.$store.getters['bqmsData/HeaderTable'].CONVEYOR_ISSUE
      //获取单号
      this.DOCNO = this.$store.getters['bqmsData/budgetSheetNum']

      if (this.orderStatus == 'Y') {
        this.btnMsg = '撤销发布'
        this.disbaledFlag = true
        this.btntype = 'danger'
      } else if (this.orderStatus == 'N') {
        this.btnMsg = '发布数据'
        this.disbaledFlag = false
        this.btntype = 'primary'
      }
    },

    //创建界面
    created() {
      if (this.tableData.length == 0) {
        this.fbDisabled = true
      } else {
        this.fbDisabled = false
      }

      //获取单据状态
      this.orderStatus = this.$store.getters['bqmsData/HeaderTable'].CONVEYOR_ISSUE

      if (this.orderStatus == 'Y') {
        this.btnMsg = '撤销发布'
        this.disbaledFlag = true
        this.btntype = 'danger'
      } else if (this.orderStatus == 'N') {
        this.btnMsg = '发布数据'
        this.disbaledFlag = false
        this.btntype = 'primary'
      }
      //如果单据状态为完成,禁用所有表单
      // if (this.orderStatus == '完成') {
      //   return 1
      // }
      //赋值请求地址
      this.postUrl = `${GFCD('bqms').domain}${GFCD('bqms').baseUrl}`
      if (this.flag) {
        this.flag = false
      }
      //请求级联下拉
      this.getSelectBrandData()
      //请求筛选下拉
      this.getScreenSel()
    },

    methods: {
      // TableDataChange(val){
      //   return this.chooseIndex = val
      // }
      //点击变色
      setCurrent(row) {
        this.$refs.singleTable.setCurrentRow(row)
      },

      //重置界面
      // initPage() {
      //   // this.epGridData1 = []
      //   // this.epGridData2 = []
      //   this.$refs['form1'].resetFields()
      //   this.form.EQUIPMENT_ID = ''
      //   this.form.EQUIPMENT_TYPE = ''
      //   this.$refs.multipleTable.clearFilter()
      // },

      //合计
      getSummaries(param) {
        const { columns, data } = param
        const sums = []
        columns.forEach((column, index) => {
          if (index === 0) {
            sums[index] = '合计'
            return
          }

          const values = data.map((item) => Number(item[column.property]))
          if (!values.every((value) => isNaN(value))) {
            if (index == 5) {
              sums[index] = values.reduce((prev, curr) => {
                const value = Number(curr)
                if (!isNaN(value)) {
                  return prev + curr
                } else {
                  return prev
                }
              }, 0)
              //sums[index] += ' 元'
            }
            // else {
            //   sums[index] = 'N/A'
            // }
          }
        })
        this.totalPrice = JSON.parse(JSON.stringify(sums[5]))
        sums[5] = Math.floor(sums[5] * 100) / 100
        return sums
      },
      //筛选下拉
      getScreenSel() {
        let method = 'bqms.conveyor.belt.model.filter'
        getList(this.postUrl, {
          method,
          data: JSON.stringify({
            DOCNO: this.$store.getters['bqmsData/budgetSheetNum'],
            '#LIMIT#': 1,
            '#PAGE_SIZE#': 9999,
          }),
        })
          .then((res) => {
            if (res.code == '00000') {
              res.data[method].data.forEach((item) => {
                console.log('item:' + JSON.stringify(item))
                this.filters.push({
                  text: item.CONVEYOR_MODEL,
                  value: item.CONVEYOR_MODEL,
                })
              })
            }
          })
          .catch((e) => {
            console.log('e', e)
          })
      },
      //单价失去焦点
      checkPrice(val, index) {
        if (!this.rule.test(val)) {
          this.$message({ type: 'error', message: '请输入大于0的单价' })
          this.epGridData2[index].PRICE_UNTAX = ''
          return
        }
      },
      //数量失去焦点
      checkQty(qty, price, index) {
        if (!this.rule.test(qty)) {
          this.$message({ type: 'error', message: '请输入大于0的数量' })
          this.epGridData2[index].QTY = ''
          return
        }

        if (!this.rule.test(price)) {
          this.$message({ type: 'error', message: '请输入大于0的单价' })
          this.epGridData2[index].QTY = ''
          return
        }
        //单价乘数量计算出金额
        this.epGridData2[index].MONEY = parseFloat(qty * price)
      },
      //金额失去焦点
      checkMoney(val, index) {
        if (!this.rule.test(val)) {
          this.$message({ type: 'error', message: '请输入大于0的数字' })
          this.epGridData2[index].MONEY = ''
          return
        }
      },
      //合并列
      objectSpanMethod({ row, column, rowIndex, columnIndex }) {
        console.log(row, column)
        //备注
        if (columnIndex === 6) {
          if (rowIndex == 0) {
            return {
              rowspan: 5,
              colspan: 1,
            }
          } else {
            return {
              rowspan: 0,
              colspan: 0,
            }
          }
        }
        //限制条件
        if (columnIndex === 3) {
          if (rowIndex == 0) {
            return {
              rowspan: 3,
              colspan: 1,
            }
          } else if (rowIndex == 3) {
            return {
              rowspan: 2,
              colspan: 1,
            }
          } else {
            return {
              rowspan: 0,
              colspan: 0,
            }
          }
        }
      },

      //重置
      resetSel(val) {
        this.form.BRAND_ID = ''
        this.$refs[val].resetFields()

        this.dialogQuery()
      },
      //模态框界面查询
      dialogQuery() {
        let method = 'bqms.motor.selection.brand.query'
        getList(this.postUrl, {
          method,
          data: JSON.stringify({
            BRAND_ID: this.form.BRAND_ID,
            '#LIMIT#': 1,
            '#PAGE_SIZE#': 9999,
            TYPE_ID: 'SSD',
          }),
        })
          .then((res) => {
            if (res.code == '00000') {
              this.epGridData1 = res.data[method].data
            }
          })
          .catch((e) => {
            console.log('e', e)
          })
      },
      //下拉框切换
      handleChange(val) {
        // console.log('val:' + val)
        // if (val != null) {
        //   this.form.TYPE_ID = val[val.length - 1]
        // }
        return val != null ? (this.form.TYPE_ID = val[val.length - 1]) : null
      },
      //保存
      savedata(row) {
        if (row.CONVEYOR_PRICE == '' || row.CONVEYOR_PRICE == null || row.CONVEYOR_PRICE.length == 0) {
          this.$message.error('无输送线价格,请先选输送带型号')
          return
        }

        //判断是否选择模态框的价格
        if (this.PRICE == '') {
          this.$message.error('请再次选择输送带型号后再保存')
          return
        }

        //判断热熔标记
        if (this.value1) {
          this.HOT_FLAG = 'Y'
        } else {
          this.HOT_FLAG = 'N'
        }

        let method = 'bqms.conveyor.belt.model.update'
        getList(this.postUrl, {
          method,
          data: JSON.stringify({
            ACTION: 'CONVEYOR',
            DOCNO: this.$store.getters['bqmsData/budgetSheetNum'],
            EQUIPMENT_ID: row.EQUIPMENT_ID, //设备ID  模态框表格选中的 EQUIPMENT_ID
            CONVEYOR_MODEL_CONFIRM: this.BRAND_ID, //确认输送带型号
            HOT_MELTING_FLAG: this.HOT_FLAG, //是否热熔
            LONGER_THAN: this.totalLen, //长度大于
            HEIGHT_GREATER_THAN: this.totalHei, //高度大于
            TOTAL_AMOUNT: this.totalPrice, //热熔费用
            NOTES: this.notes, //备注
          }),
        })
          .then((res) => {
            if (res.code == '00000') {
              this.onQuery()
              //清空之前提交的数据
              this.BRAND_ID = ''
              this.HOT_FLAG = ''
              this.totalLen = ''
              this.totalHei = ''
              this.totalPrice = ''
              this.notes = ''
              this.PRICE = ''
            }
          })
          .catch((e) => {
            console.log('e', e)
          })
      },
      reset(val) {
        this.$refs[val].resetFields()
        this.form.EQUIPMENT_ID = ''
        this.form.TYPE_ID = ''
        this.form.CONVEYOR_MODEL = ''
        this.$refs.multipleTable.clearFilter()
        this.onQuery()
      },
      //获取级联数据
      getSelectBrandData() {
        let method = 'bqms.type.manage.query'
        getList(this.postUrl, {
          method,
          data: JSON.stringify(this.selectFormData),
        }).then((res) => {
          if (res.code == '00000') {
            this.srcArr = res.data[method].data
            // this.$message({
            //   message: res.msg,
            //   type: 'success',
            // })
            //this.options = res.data[method].data

            //一级级联
            res.data[method].data.forEach((val) => {
              if (val.PARAENT_TYPE_ID == 0) {
                this.options.push({
                  parentId: val.PARAENT_TYPE_ID, //级联父ID
                  label: val.TYPE_NAME, //级联名称
                  value: val.TYPE_ID, //级联ID
                  children: [],
                })
              }

              this.options.forEach((item) => {
                item.children = this.getChildren(item.value, this.srcArr)
              })
              this.settingJson.Steel.serBox.forEach((v) => {
                if (v.type == 'cascader' && v.label == '设备类型：') {
                  v.options = this.options
                }
              })
            })
          } else {
            this.$message({ type: 'error', message: res.msg })
          }
        })
      },
      // 处理级联--递归
      getChildren(tId, srcArr) {
        let children = []
        srcArr.forEach((item) => {
          if (item.PARAENT_TYPE_ID == tId) {
            children.push({
              parentId: item.PARAENT_TYPE_ID,
              value: item.TYPE_ID,
              label: item.TYPE_NAME,
              children: [],
            })
          }
        })
        if (children.length == 0) {
          return null
        }
        children.forEach((item) => {
          item.children = this.getChildren(item.value, this.srcArr)
        })
        return children
      },

      //隐藏界面确定
      confirmMsg() {
        if (this.PRICE.length == 0) {
          this.$message.error('请选中一行品牌再进行操作')
          return
        }

        //选中的型号显示到首页表格中
        this.tableData[this.tabledataIndex].CONVEYOR_EQUIPMENT_MODEL = this.EQUIPMENT_NO

        this.tableData[this.tabledataIndex].CONVEYOR_PRICE = this.PRICE

        //获取上一界面点击行数的下标
        //let choiceData = this.tableData[this.tabledataIndex]

        //带出该行价格,输送带型号

        //循环带出价格,输送带型号
        // this.tableData.forEach((item) => {
        //   if (choiceData.CONVEYOR_MODEL != '') {
        //     if (item.CONVEYOR_MODEL == choiceData.CONVEYOR_MODEL) {
        //       item.CONVEYOR_MODEL_CONFIRM = choiceData.CONVEYOR_MODEL_CONFIRM
        //       item.CONVEYOR_PRICE = this.PRICE
        //     }
        //   } else {
        //     item.CONVEYOR_MODEL_CONFIRM = choiceData.CONVEYOR_MODEL_CONFIRM
        //     item.CONVEYOR_PRICE = this.PRICE
        //   }
        // })

        //缓存长度大于,高度大于,备注
        this.totalLen = this.epGridData2[0].XZTJ
        this.totalHei = this.epGridData2[3].XZTJ
        this.notes = this.epGridData2[0].NOTES
        this.dialogTableVisible = false

        this.getObj('grid2').style.display = 'none'
      },
      //获取DOM元素
      getObj(id) {
        return document.getElementById(id)
      },
      //隐藏界面显示下部分列表
      showTable() {
        console.log(this.value1)
        if (this.value1) {
          this.getObj('grid2').style.display = 'block'
        } else {
          this.getObj('grid2').style.display = 'none'
        }
      },
      //单选标记
      selectRow(val) {
        if (val.length > 1) {
          this.$refs.selectTable.clearSelection()
          this.$refs.selectTable.toggleRowSelection(val.pop())
        }
      },
      //获取选中数据
      selectData(val, row) {
        this.EQUIPMENT_NO = row.EQUIPMENT_MODEL
        this.PRICE = row.PRICE_UNTAX
        this.BRAND_ID = row.EQUIPMENT_ID
      },
      //界面1表格选择按钮
      chooseClick(row, index) {
        console.log('index123:' + index)
        //缓存选中下标
        this.chooseIndex = index
        //该行变色
        //this.tableRowClassName()
        this.value1 = false
        console.log('rowrow:' + JSON.stringify(row))

        //缓存选中行下标
        this.tabledataIndex = index
        //初始化
        //this.resetSel('form2')
        this.form.BRAND_ID = ''
        this.epGridData1 = []
        //this.epGridData2 = []
        this.brandOptions = []

        // this.EQUIPMENT_NO = ''
        // this.PRICE = ''
        // this.totalLen = ''
        // this.totalHei = ''
        // this.notes = ''

        this.epGridData2.forEach((item) => {
          item.PRICE_UNTAX = ''
          item.XZTJ = ''
          item.QTY = ''
          item.MONEY = ''
        })

        this.epGridData2[0].NOTES = row.NOTES

        console.log('row.NOTES:' + row.NOTES)

        this.epGridData1.forEach((item) => {
          item.checked = false
        })

        let method = 'bqms.brand.query'
        getList(this.postUrl, {
          method,
          data: JSON.stringify({
            '#LIMIT#': 1,
            '#PAGE_SIZE#': 9999,
            TYPE_ID: 'SSD',
          }),
        })
          .then((res) => {
            console.log('res', res)

            if (res.code == '00000') {
              //加载下拉框

              res.data[method].data.forEach((item) => {
                console.log('item', item)
                this.brandOptions.push({
                  label: item.BRAND_NAME,
                  value: item.BRAND_ID,
                })
              })

              console.log('this.brandOptions' + this.brandOptions)
            }
          })
          .catch((e) => {
            console.log('e', e)
          })

        this.dialogTableVisible = true
      },
      //筛选确定
      filterTag(value, row) {
        console.log('row.CONVEYOR_MODEL_CONFIRM ', row.CONVEYOR_MODEL)
        return row.CONVEYOR_MODEL == value
      },
      //发布数据
      onSubmit() {
        if (this.btnMsg == '发布数据') {
          this.$confirm('是否确认发布', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
          })
            .then(() => {
              //判断确认输送带型号，输送线价格，是否热熔，热熔费用是否为空

              this.checkDataFlag = this.tableData.some(function (item) {
                return item.CONVEYOR_MODEL_CONFIRM == '' || item.CONVEYOR_PRICE == '' || item.HOT_MELTING_FLAG == '' || item.HOT_MELTING_PRICE == ''
              })

              console.log('this.checkDataFlag:' + this.checkDataFlag)
              if (this.checkDataFlag) {
                this.$message({
                  message: '请把表格中输送带型号，输送线价格，是否热熔，热熔费用填写完全！',
                  type: 'warning',
                })
                return
              }
              //发布数据调用SP
              let method = 'bqms.common.sp.release'
              getList(this.postUrl, {
                method,
                data: JSON.stringify({ TYPE: 'CONVEYOR_ISSUE', DOCNO: this.$store.getters['bqmsData/budgetSheetNum'] }),
              })
                .then((res) => {
                  console.log('res', res)
                  if (res.code == '00000') {
                    this.$message({
                      message: '发布数据成功',
                      type: 'success',
                    })
                    //禁用所有表单编辑,改变按钮名字
                    this.btnMsg = '撤销发布'
                    this.disbaledFlag = true
                    this.btntype = 'danger'
                    // 刷新表头
                    this.$pub(`topFormData`, true)
                  } else {
                    this.$message.error(res.data.OUT_RETURN_CODE)
                  }
                })
                .catch((e) => {
                  console.log('e', e)
                })
            })
            .catch(() => {
              this.$message({
                type: 'info',
                message: '已取消',
              })
            })
        } else {
          this.$confirm('是否撤销发布', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
          })
            .then(() => {
              //撤销发布数据调用SP
              let method = 'bqms.common.reverseRelease'
              getList(this.postUrl, {
                method,
                data: JSON.stringify({ TYPE: 'CONVEYOR_ISSUE', DOCNO: this.$store.getters['bqmsData/budgetSheetNum'] }),
              })
                .then((res) => {
                  console.log('res', res)
                  if (res.code == '00000') {
                    this.$message({
                      message: '撤销发布成功',
                      type: 'success',
                    })
                    //禁用所有表单编辑,改变按钮名字
                    this.btnMsg = '发布数据'
                    this.disbaledFlag = false
                    this.btntype = 'primary'
                    // 刷新表头
                    this.$pub(`topFormData`, true)
                  } else {
                    this.$message.error(res.data.OUT_RETURN_CODE)
                  }
                })
                .catch((e) => {
                  console.log('e', e)
                })
            })
            .catch(() => {
              this.$message({
                type: 'info',
                message: '已取消',
              })
            })
        }
      },
      //查询按钮
      onQuery() {
        let method = 'quotationServiceImpl.query'
        if (this.$store.getters['bqmsData/HeaderTable'].BASIC_DATA_ISSUE == 'N') return this.$message.error('基础数据未发布')
        getList(this.postUrl, {
          method,
          data: JSON.stringify({
            '#LIMIT#': 1,
            '#PAGE_SIZE#': 9999,
            OUT_SOURCE: 'N',
            EQUIPMENT_ID: this.form.EQUIPMENT_ID,
            DOCNO: this.$store.getters['bqmsData/budgetSheetNum'],
            TYPE_ID: this.form.TYPE_ID,
            CONVEYOR_MODEL: this.form.CONVEYOR_MODEL,
          }),
        })
          .then((res) => {
            //console.log('res', res)

            if (res.code == '00000') {
              this.tableData = res.data
              if (this.tableData.length == 0) {
                this.fbDisabled = true
              } else {
                // this.$message({
                //   message: '操作成功',
                //   type: 'success',
                // })
                this.fbDisabled = false
              }
            } else {
              this.tableData = []
              this.fbDisabled = true
            }
          })
          .catch((e) => {
            console.log('e', e)
            this.fbDisabled = true
          })
      },
    },
  }
</script>
<style lang="scss">
  @import '@bqms/static/scss/Common.scss';
  .ConveyorModel {
    width: calc(100% - 40px);
    padding: 20px;
  }

  .above {
    height: 30%;
  }
  .type {
    background-color: Gainsboro;
  }
  /* .el-input {
    width: 200px;
  } */
  .tableForm {
    margin-top: 2%;
    height: 10%;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .detailTable {
    height: 60%;
  }
  .rightbtn {
    right: 5%;
    position: absolute;
    bottom: 2%;
  }
  .more_btn thead .el-table-column--selection .cell {
    display: none;
  }
  .el-table .warning-row {
    background: oldlace;
  }
</style>
